{extend name=".././view/list.html" /}
{block name="jsset"}
{/block}
{block name="nav"}
<span class="layui-breadcrumb">
	<a href="">教务管理</a>
	<a href="">班级管理</a>
	<a><cite>{$list['webtitle']}</cite></a>
</span>
{/block}
{block name="search"}
<div class="layui-form-item">
	<label for="searchval" class="layui-form-label">
		关键字
	</label>
	<div class="layui-input-block">
		<input type="text" id="searchval" name="searchval" autocomplete="off" class="layui-input" placeholder="输入关键字并回车">
	</div>
</div>
<div class="layui-form-item">
	<label for="xueqi_id" class="layui-form-label" class="layui-input">学期</label>
	<div class="layui-input-block">
		<select name="xueqi_id" id="xueqi_id">
		</select>
	</div>
</div>
<div class="layui-form-item">
	<label for="category_id" class="layui-form-label">考试类型</label>
	<div class="layui-input-block">
		<select name="category_id" id="category_id">
		</select>
	</div>
</div>
<div class="layui-form-item">
	<div class="layui-inline">
		<label for="title" class="layui-form-label">
			<span class="x-red">*</span>考试时间
		</label>
		<div class="layui-input-inline">
			<input type="text" class="layui-input" id="bfdate" name="bfdate" placeholder="起始：默认二年前的今天" value="{$list.data.bfdate|default=''}" autocomplete="off" lay-filter="riqi">
		</div>
		<div class="layui-input-inline">
			<input type="text" class="layui-input" id="enddate" name="enddate" placeholder="结束：默认明天" value="{$list.data.enddate|default=''}" autocomplete="off" lay-filter="riqi">
		</div>
	</div>
</div>
<input type="hidden" name="banji_id" value="{$list.banji_id}">
<div class="layui-form-item" style="text-align: right;">
	<button class="layui-btn" lay-filter="srcSubmit" lay-submit="">搜索</button>
</div>
{/block}
{block name="table"}
<table id="tabledemo" lay-filter="mytable" lay-size="sm"></table>
{/block}
{block name="echart"}
{volist name="$list.subject_id" id="vo"}
<div class="layui-col-xs6" style="width:100%; height:400px; margin-top: 45px; margin-bottom: 45px;" id="{$vo.lieming}"></div>
{/volist}
{/block}
{block name="myjs"}
<!-- 表格上面按钮模板 -->
<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
  <button class="layui-btn" lay-event="download">
   <i class="layui-icon layui-icon-download-circle"></i> 下载
 </button>
</div>
</script>
<!-- 记录操作按钮模板 -->
<script type="text/html" id="barDemo">
	<!-- <a class="layui-btn-xs" lay-event="edit" title="编辑"><i class="layui-icon">&#xe642;</i></a> -->
	<!-- <a class="layui-btn-xs" lay-event="del" title="删除"><i class="layui-icon">&#xe640;</i></a> -->
</script>
<!-- 表格操作 -->
<script>
// 提交搜索条件后重载表格
layui.use(['table', 'mytable', 'laydate', 'myEchart', 'createInput'], function() {
	var table = layui.table,
		mytable = layui.mytable,
		form = layui.form,
		laydate = layui.laydate,
		echart = layui.myEchart,
		cInput = layui.createInput;

	cInput.categorySelect('xueqi_id', 108);
	cInput.categorySelect('category_id', 109);

	// 设置列
	options.cols = [
		[ //表头
			{ type: 'numbers', title: '序号', rowspan: 2 },
			{ field: 'ks_title', title: '考试名称', sort: false, minWidth: 80, rowspan: 2 },
		],
		[]
	];
	// 获取学科
	var xk = '<?php echo json_encode($list["subject_id"]);?>';
	xk = eval(decodeURIComponent(xk));
	var xiangmu = '<?php echo json_encode($list["tjxm"]);?>'; // 要显示哪些统计结果
	xiangmu = eval(decodeURIComponent(xiangmu));
	xiangmuCnt = xiangmu.length;

	$.each(xk, function(index, value) {
		options.cols[0].push({ title: xk[index].title, colspan: xiangmuCnt, align: 'center' });
		$.each(xiangmu, function(i, val) {
			var colname = xk[index].lieming;
			var colinfo = {
				title: val.title,
				minWidth: 100,
				templet: function(d) {
					var str = "";
					if (d.chengji) {
						if (d.chengji[colname]) {
							str = d.chengji[colname][val.biaoshi];
						}
					}
					return str;
				}
			};
			options.cols[1].push(colinfo);
		});
	});
	options.cols[0].push({
		title: '全科及格率%',
		minWidth: 100,
		rowspan: 2,
		templet: function(d) {
			var str = d.quanke.jigelv;
			return str;
		}
	});
	options.cols[0].push({
		title: '总平均分',
		minWidth: 100,
		rowspan: 2,
		templet: function(d) {
			var str = d.quanke.avg;
			return str;
		}
	});

	//开始时间
	laydate.render({
		elem: '#bfdate',
		type: 'datetime',
		trigger: 'click', //采用click弹出
		format: 'yyyy-M-d', //可任意组合
	});
	//结束时间
	laydate.render({
		elem: '#enddate',
		type: 'datetime',
		trigger: 'click', //采用click弹出
		format: 'yyyy-M-d', //可任意组合
	});

	getDefenlv();

	// 条形统计图--平均分
	function getDefenlv() {
		val = form.val('search');
		// 添加图表中内容
		for (x in xk) {
			echart.zhexian(xk[x].lieming, '/teach/banjicj/datatx', val, xk[x].title);
		}
	}

	// 监听筛选
  form.on('submit(srcSubmit)', function(data) {
    options.where = form.val("search");
    $('#srcmianban').removeClass("layui-show");
    table.render(options); //获取数据并渲染
    getDefenlv();
    return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
  });

});

</script>
{/block}
